package com.example.es.restclient.listener;

import com.example.es.restclient.constants.HotelMqConstants;
import com.example.es.restclient.service.HotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelListener {

	@Autowired
	private HotelService hotelService;

	/**
	 * 监听酒店新增或修改的业务
	 *
	 * @param id
	 */
	@RabbitListener(queues = HotelMqConstants.hotel_inset_queue)
	public void listenHotelInsertOrUpdate(String id) {
		hotelService.insertById(new Long(id) );
	}


	@RabbitListener(queues = HotelMqConstants.hotel_delete_queue)
	public void listenHotelDelete(String id) {
		hotelService.deleteById(new Long(id));
	}
}
